<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>限时抢</title>
<!-- <link rel="stylesheet" href="style.css"  /> -->
</head>

</head>
<body>
   <div class="content3">
    <div class="time">还剩<span  id="LefTime"></span></div>
   </div>

   <script language="javascript" type="text/javascript">
       window.onload = function(){
            showTime();
       }
       function showTime() {
           var endtime= new Date("2018/5/15,12:20:12");     //自定义结束时间
           var curtime =  new Date();    //获取当前时间
           var millisecondTime = parseInt((endtime.getTime() - curtime.getTime()) / 1000);    //得出的为毫秒
           var d = parseInt(millisecondTime / (24*60*60));  //天
           var h = parseInt(millisecondTime /(60*60) % 24);    //小时
           var m = parseInt(millisecondTime / 60 % 60); //分钟
           var s = parseInt(millisecondTime % 60);  //秒
           //alert(s);

           document.getElementById('LefTime').innerHTML = d+'天'+h+'小时'+m+'分'+s+'秒';
           if (millisecondTime <= 0){
               document.getElementById('LefTime').innerHTML = '团购结束';
           }
           //setTimeout(showTime,500);    //此方法用于在指定的毫秒数后调用函数或计算表达式  //方法一 使用 setTimeout 函数
       }

       var sh;
       sh = setInterval(showTime, 1000); //方法二 使用setInterval函数实现
   </script>

</body>
</html>